﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Runtime.InteropServices;
using System.Web;
using U8Login;
//using UFIDA.U8.MomServiceCommon;
//using UFIDA.U8.U8MOMAPIFramework;
//using UFIDA.U8.U8APIFramework;
//using UFIDA.U8.U8APIFramework.Meta;
//using UFIDA.U8.U8APIFramework.Parameter;
//using MSXML2;


namespace BaoShouTangServer.Service
{

        public static class LogInService
        {
            

            public static clsLogin GetLogin( ref string resp, ref string msg, string AccID = "241")
            {
            //clsLogin login = (clsLogin)Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("3DEF0145-E1BE-4D82-BD72-AB5939CDDAA8")));
            U8Login.clsLogin login = new U8Login.clsLogin();


            string sSubId = "AS";
                string sAccID = AccID;
                string sYear = "2024";
                string sUserID = "demo";
                string sPassword = "DEMO";
                string sDate = DateTime.Now.ToString("yyyy-MM-dd");
            string sServer = ConfigurationManager.AppSettings["u8server"].ToString();
            string sSerial = "";
                bool flag = string.IsNullOrEmpty(sDate);
                if (flag)
                {
                    sDate = DateTime.Now.ToString("yyyy-MM-dd");
            }
                bool flag2 = !login.Login(ref sSubId, ref sAccID, ref sYear, ref sUserID, ref sPassword, ref sDate, ref sServer, ref sSerial);
                if (flag2)
                {
                    resp = "登陆失败";
                    msg = "登陆失败,原因：" +
                        login.ShareString;
                    throw new Exception(msg);
                }
                else
                {
                    resp = "登陆成功";
                }
                return login;
            }
        }
}